package com.noreply.demo.controller;

import com.noreply.demo.dto.Resp;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author
 * @description
 * @datetime 2021/6/23 17:17
 */
public class BaseController {
    @ExceptionHandler(ArithmeticException.class)
    public Resp errorHandle(Exception e) {
        return fail("base", e);
    }

    public Resp success(Object data) {
        return new Resp(data);
    }

    public Resp fail(String message, Object data) {
        return new Resp(1, message, data);
    }
}
